<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org"
      xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity3">
<meta charset="UTF-8" />
<head>
<title>登陆页面</title>
<script type="text/javascript" th:src="@{/js/jquery.min.js}"></script>
</head>
<body>
<div><label> 账号: <input type="text" id="username" value="admin" /> </label></div>
<div><label> 密码: <input type="password" id="password" value="admin" /> </label></div>
<div><input type="button" value="登陆" onclick="login();"/></div>
<div>
    <p>管理员用户：admin，密码：admin，权限：发送广播和聊天消息，接收广播和聊天消息</p>
    <p>普通用户：user，密码：user，权限：发送聊天消息，接收广播和聊天消息</p>
    <p>访客用户：guest，密码：guest，权限：接收广播</p>
</div>
<script type="text/javascript">
    function login() {
        var username = $("#username").val();
        var password = $("#password").val();
        $.ajax({
            url: "/login",
            type: "post",
            data: {
                username: username,
                password: password
            },
            datatype: "json",
            success: function(data) {
                console.log(data);
                if (data==="ok") {
                    location.href = "/index";
                }
            },
            error: function(xhr, msg, e) {
                console.error(e);
            }
        });
    }
</script>
</body>
</html>
